package org.darcy.youchat.fragment;

import static org.darcy.youchat.R.id.tvOne;
import static org.darcy.youchat.R.id.tvTwo;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import org.darcy.youchat.R;
import org.darcy.youchat.activity.message.LocationActivity;
import org.darcy.youchat.activity.message.RedPacketActivity;
import org.darcy.youchat.activity.message.SessionActivity;
import org.darcy.youchat.activity.message.TransferActivity;
import org.darcy.youchat.databinding.FragmentFuncPage1Binding;
import org.darcy.youchat.library.imagepicker.ui.ImageGridActivity;
import org.darcy.youchat.utils.UIUtils;
import org.darcy.youchat.view.CustomDialog;

/**
 * 聊天界面功能页面1
 */
public class Func1Fragment extends BaseFragment {

    private FragmentFuncPage1Binding binding;

    private View mContentView;
    private CustomDialog mDialog; //二选一对话框
    private TextView mTvOne;
    private TextView mTvTwo;
    Intent mIntent;

    @Override
    public View initView() {
        binding = FragmentFuncPage1Binding.inflate(getLayoutInflater());
        return binding.getRoot();
    }

    @Override
    public void initListener() {
        //1.发图
        binding.llPic.setOnClickListener(v->{
            mIntent = new Intent(getActivity(), ImageGridActivity.class);
            startActivityForResult(mIntent, SessionActivity.IMAGE_PICKER);
        });
        //2.视频
        binding.llRecord.setOnClickListener(v-> ((SessionActivity)getActivity()).showPlayVideo());
        //3.红包
        binding.llRedPacket.setOnClickListener(v->{
            mIntent = new Intent(getActivity(), RedPacketActivity.class);
            startActivity(mIntent);
        });
        //4.转账
        binding.llTransfer.setOnClickListener(v->{
            mIntent = new Intent(getActivity(), TransferActivity.class);
            startActivity(mIntent);
        });
        //5.我的收藏
        binding.llCollection.setOnClickListener(v-> UIUtils.showToast("我的收藏，暂未开发，敬请期待"));
        //6.位置
        binding.llLocation.setOnClickListener(v->{
            mContentView = View.inflate(getActivity(), R.layout.dialog_menu_two_session, null);
            mDialog = new CustomDialog(getActivity(), mContentView, R.style.dialog);
            mDialog.show();
            mTvOne = mContentView.findViewById(tvOne);
            mTvTwo = mContentView.findViewById(tvTwo);
            mTvOne.setText("发送位置");
            mTvTwo.setText("共享实时位置");
            mTvOne.setOnClickListener(v2 -> {
                mDialog.dismiss();
                mIntent = new Intent(getActivity(), LocationActivity.class);
                startActivity(mIntent);
            });
            mTvTwo.setOnClickListener(v2 -> mDialog.dismiss());
        });
        //7.视频聊天
        binding.llVideo.setOnClickListener(v->{
            mContentView = View.inflate(getActivity(), R.layout.dialog_menu_two_session, null);
            mDialog = new CustomDialog(getActivity(), mContentView, R.style.dialog);
            mDialog.show();
            mTvOne = mContentView.findViewById(tvOne);
            mTvTwo = mContentView.findViewById(tvTwo);
            mTvOne.setText("视频聊天");
            mTvTwo.setText("语音聊天");
            mTvOne.setOnClickListener(v2 -> mDialog.dismiss());
            mTvTwo.setOnClickListener(v2-> mDialog.dismiss());
        });
        //8.名片
        binding.llBusinessCard.setOnClickListener(v-> UIUtils.showToast("名片，暂未开发，敬请期待"));

    }

}
